﻿/***********************************************************************************************************************************
 *    Name: ShrinkLog.sql
 *  Author: Frank Figearo — http://www.sqlnerd.me/ — frank@sqlnerd.me
 * Summary:	
 */
SET IMPLICIT_TRANSACTIONS OFF; IF 0 < @@TRANCOUNT ROLLBACK;
GO
CREATE PROCEDURE #ShrinkLog (@db SYSNAME) AS
DECLARE @tsql_script NVARCHAR(MAX)= N'USE [' + @db + N']; CHECKPOINT; DBCC SHRINKFILE(2,0);';
EXECUTE (@tsql_script);
GO
SELECT N'EXECUTE #ShrinkLog ''' + name + N''';'FROM sys.databases WHERE 4 <database_id;
GO